using System.Collections;
using System.Collections.Generic;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;
using UnityEngine;

public class BTEnemyBatFly : Action
{
    private Transform player;
    private EnemyBat enemyBat;
    public override void OnAwake()
    {
        
        enemyBat=gameObject.GetComponent<EnemyBat>();
        
    }
    public override TaskStatus OnUpdate()
    {
        
        if (player != null)
        {

            Vector3 vec;
            vec = player.transform.position - transform.position;

            
            vec.Normalize();
            transform.position += vec * Time.deltaTime * enemyBat.runSpeed;
            

        }
        else
        {
            player = enemyBat.player;
        }
        return TaskStatus.Success;
    }
    
}
